using System;
using System.Collections;

namespace VoxelEngine.TerrainGenerator
{
	[Serializable]
	public class ARBlockTerrainGenerator : TerrainGenerator
	{
		public override IEnumerator CreateWorldFromSeed(World world)
		{
			for (int i = 0; i < world.WorldVisibleSizeX; i++)
			{
				for (int j = 0; j < world.WorldVisibleSizeZ; j++)
				{
					ChunkRenderer.WorldHeight[i, j] = 2f;
					for (int k = 0; k < world.WorldVisibleSizeY; k++)
					{
						CreateColumn(world, i, k, j);
					}
				}
			}
			yield return null;
		}

		private void CreateColumn(World world, int x, int y, int z)
		{
			switch (y)
			{
			case 0:
				world[x, y, z] = new Block(BlockType.HardStone, x, y, z);
				break;
			case 1:
				world[x, y, z] = new Block(BlockType.Grass, x, y, z);
				break;
			case 2:
				world[x, y, z] = new Block(BlockType.Height, x, y, z);
				break;
			default:
				world[x, y, z] = new Block(BlockType.Air, x, y, z)
				{
					Light = byte.MaxValue
				};
				break;
			}
		}
	}
}
